package com.example.myapplication.ui.adapter

import android.os.Build
import androidx.annotation.RequiresApi
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.myapplication.R
import com.example.myapplication.bean.coins.CoinRecordBean
import kotlinx.android.synthetic.main.item_coins_record.view.*

/**
 *积分流水
 *
 * @author : Kun
 * @date : 2021/6/11
 * @time : 13:31
 */
class CoinsRecordAdapter(layoutResId: Int, mList: ArrayList<CoinRecordBean>?) :
    BaseQuickAdapter<CoinRecordBean, BaseViewHolder>(layoutResId, mList), LoadMoreModule {

    @RequiresApi(Build.VERSION_CODES.M)
    override fun convert(holder: BaseViewHolder, item: CoinRecordBean) {
        holder.setText(R.id.tv_reason, item.reason)
            .setText(R.id.tv_time, item.desc)
            .setText(
                R.id.tv_coins,
                if (item.coinCount >= 0) "+" + item.coinCount else "" + item.coinCount
            )

        holder.setTextColor(
            R.id.tv_coins,
            context.getColor(if (item.coinCount >= 0) R.color.c_33cc66 else R.color.c_ff3333)
        )
    }
}